#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char const *argv[])
{
    // setlocale(LC_ALL, "zh_CN.utf8");
    int len;
    char *pmbnull = NULL;
    char *pmb = (char *)malloc(MB_CUR_MAX);
    wchar_t *pwc = L"Hi 中国";
    wchar_t *pwcs = (wchar_t *)malloc(sizeof(wchar_t));

    printf("转换为多字节字符串\n");
    len = wcstombs(pmb, pwc, MB_CUR_MAX);
    printf(u8"被转换的字符 %d\n", len);
    printf("第一个多字节字符的十六进制值：%#.4x\n", pmb);

    printf("转换回宽字符字符串\n");
    len = mbstowcs(pwcs, pmb, MB_CUR_MAX);
    printf("被转换的字符 %d\n", len);
    printf("第一个宽字符的十六进制值：%#.4x\n\n", pwcs);

    delete pmb;
    delete pwcs;


    return 0;
}
